<?php 
require 'Model.php';
class TypeModel extends Model{
	function __Construct(){
		parent::__Construct();
		$this->mod='videotype';
	}
	function getList()
	{
		$sql="select * from {$this->mod}";
		$data=$this->conn->query($sql);
		return $data;
	}
		function add2($data)
		{

			$type = array(
				'typename' => $data['typename']
				);
			$keys = implode(',',array_keys($type));
			$values = implode("','", array_values($type));
			$sql="insert into videotype ({$keys}) VALUES ('{$values}')";

			$result = $this->conn->query($sql);
			return $result;
		}
		function getTypeByID($id){
			$sql = "select * from videotype where tid=".$id;
			$result = $this->conn->query($sql);
			return $result;
		}
		function update2($data)
		{
			$user = array(
				'typename' => $data['typename']  
				);
		
			$sets = '';
			foreach ($user as $key=>$val){
				$sets.=$key."='".$val."',";
			}
			    $sets=rtrim($sets,','); //去掉SQL里的最后一个逗号
			    
			    $sql="UPDATE videotype SET {$sets} where tid=".$data['id'];
			  //执行SQL语句
			    $result = $this->conn->query($sql);
			    return $result;		    
			}
				function delete2($id)
			{
				$sql = "delete from videotype where tid=".$id;
				$result = $this->conn->query($sql);
				return $result;
			}
}


 ?>